package com.yowasa.xiuxian.entity.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum EventType {

    READY(null),//连接准备就绪事件

    GUILD_CREATE(IntentsEnum.GUILDS),//当机器人加入新guild时
    GUILD_UPDATE(IntentsEnum.GUILDS),//当guild资料发生变更时
    GUILD_DELETE(IntentsEnum.GUILDS),//当机器人退出guild时
    CHANNEL_CREATE(IntentsEnum.GUILDS),//当channel被创建时
    CHANNEL_UPDATE(IntentsEnum.GUILDS),//当channel被更新时
    CHANNEL_DELETE(IntentsEnum.GUILDS),//当channel被删除时

    GUILD_MEMBER_ADD(IntentsEnum.GUILD_MEMBERS),//当成员加入时
    GUILD_MEMBER_UPDATE(IntentsEnum.GUILD_MEMBERS),//当成员资料变更时
    GUILD_MEMBER_REMOVE(IntentsEnum.GUILD_MEMBERS),//当成员被移除时

    MESSAGE_CREATE(IntentsEnum.GUILD_MESSAGES),//发送消息事件，代表频道内的全部消息，而不只是 at 机器人的消息。内容与 AT_MESSAGE_CREATE 相同
    MESSAGE_DELETE(IntentsEnum.GUILD_MESSAGES),//删除（撤回）消息事件

    MESSAGE_REACTION_ADD(IntentsEnum.GUILD_MESSAGE_REACTIONS),//为消息添加表情表态 
    MESSAGE_REACTION_REMOVE(IntentsEnum.GUILD_MESSAGE_REACTIONS),//为消息删除表情表态

    DIRECT_MESSAGE_CREATE(IntentsEnum.DIRECT_MESSAGE),//当收到用户发给机器人的私信消息时
    DIRECT_MESSAGE_DELETE(IntentsEnum.DIRECT_MESSAGE),//删除（撤回）消息事件

    OPEN_FORUM_THREAD_CREATE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户创建主题时
    OPEN_FORUM_THREAD_UPDATE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户更新主题时
    OPEN_FORUM_THREAD_DELETE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户删除主题时
    OPEN_FORUM_POST_CREATE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户创建帖子时
    OPEN_FORUM_POST_DELETE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户删除帖子时
    OPEN_FORUM_REPLY_CREATE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户回复评论时
    OPEN_FORUM_REPLY_DELETE(IntentsEnum.OPEN_FORUMS_EVENT),//当用户删除评论时

    AUDIO_OR_LIVE_CHANNEL_MEMBER_ENTER(IntentsEnum.AUDIO_OR_LIVE_CHANNEL_MEMBER),//当用户进入音视频/直播子频道
    AUDIO_OR_LIVE_CHANNEL_MEMBER_EXIT(IntentsEnum.AUDIO_OR_LIVE_CHANNEL_MEMBER),//当用户离开音视频/直播子频道

    INTERACTION_CREATE(IntentsEnum.INTERACTION),//互动事件创建时

    MESSAGE_AUDIT_PASS(IntentsEnum.MESSAGE_AUDIT),//消息审核通过
    MESSAGE_AUDIT_REJECT(IntentsEnum.MESSAGE_AUDIT),//消息审核不通过;

    FORUM_THREAD_CREATE(IntentsEnum.FORUMS_EVENT),//当用户创建主题时
    FORUM_THREAD_UPDATE(IntentsEnum.FORUMS_EVENT),//当用户更新主题时
    FORUM_THREAD_DELETE(IntentsEnum.FORUMS_EVENT),//当用户删除主题时
    FORUM_POST_CREATE(IntentsEnum.FORUMS_EVENT),//当用户创建帖子时
    FORUM_POST_DELETE(IntentsEnum.FORUMS_EVENT),//当用户删除帖子时
    FORUM_REPLY_CREATE(IntentsEnum.FORUMS_EVENT),//当用户回复评论时
    FORUM_REPLY_DELETE(IntentsEnum.FORUMS_EVENT),//当用户删除评论时
    FORUM_PUBLISH_AUDIT_RESULT(IntentsEnum.FORUMS_EVENT),//当用户发表审核通过时

    AUDIO_START(IntentsEnum.AUDIO_ACTION),//音频开始播放时
    AUDIO_FINISH(IntentsEnum.AUDIO_ACTION),//音频播放结束时
    AUDIO_ON_MIC(IntentsEnum.AUDIO_ACTION),//上麦时
    AUDIO_OFF_MIC(IntentsEnum.AUDIO_ACTION),//下麦时

    AT_MESSAGE_CREATE(IntentsEnum.PUBLIC_GUILD_MESSAGES),//当收到@机器人的消息时
    PUBLIC_MESSAGE_DELETE(IntentsEnum.PUBLIC_GUILD_MESSAGES),//当频道的消息被删除时


    ;
    private IntentsEnum intent;

    public boolean eq(String type) {
        return this.name().equals(type);
    }

    public static EventType getByName(String name) {
        return Arrays.stream(EventType.values()).filter(e -> e.name().equals(name)).findFirst().orElse(null);
    }
}
